<h2>添加后端用户</h2>
<div class="col-md-12" style="padding-left:0px;">
    <div class="panel panel-default">
        <div class="panel-heading">
            <span class="app-panel-title" >填写用户的基本资料</span>
            <a class="btn btn-sm btn-success app-panel-btn" href="/manage/operate/index/"> <i class="glyphicon glyphicon-chevron-right"></i> 返回用户列表</a>
            <div style="clear:both;"></div>
        </div>

        <div class="panel-body">
            <?php if(!empty($message)):?>
                <div class="alert alert-danger">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <?php echo htmlspecialchars($message)?>
                </div>
            <?php endif;?>
            <form action="/manage/operate/create" method="post" role="form" id="user-form">

                <?php if(!empty($user_data)):?>
                    <input type="hidden" name="uid" value="<?php echo $user_data['uid']?>" />
                <?php endif;?>

                <div class="form-group">
                    <label for="username">昵称</label>
                    <input type="text" class="form-control" name="username" <?php if(!empty($user_data)):?>value="<?php echo $user_data['username']?>" <?php endif;?> id="username" placeholder="">
                    <span class="help-block error"></span>
                </div>
                <div class="form-group">
                    <label for="email">邮箱</label>
                    <input type="text" class="form-control" name="email" <?php if(!empty($user_data)):?>value="<?php echo $user_data['email']?>" <?php endif;?> id="email" placeholder="">
                    <span class="help-block error"></span>
                </div>
                <?php if(empty($user_data)):?>
                    <div class="form-group">
                        <label for="password">密码</label>
                        <input type="password" class="form-control" name="password" <?php if(!empty($user_data)):?>value="<?php echo $user_data['password']?>" <?php endif;?> id="password" placeholder="">
                        <span class="help-block error"></span>
                    </div>
                <?php endif;?>

                <button type="submit" class="btn btn-default" >提交</button>
            </form>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
    $("#user-form").validate({
        rules: {
            username: { required: true },
            email: { required:true },
            password: {required:true}
        },
        messages: {
            username: {
                required: "昵称不能为空"
            },
            email: {
                required: "邮箱不能为空"
            },
            password: {
                required:"密码不能为空"
            }
        },
        errorElement: "span",
        errorPlacement: function(error, element) {
            element.nextAll("span.error").replaceWith(error) ;
        }
    });
</script>